
//
//  EmotionCell.swift
//  Emotion
//
//  Created by maker on 2016/11/21.
//  Copyright © 2016年 maker. All rights reserved.
//

import UIKit

class EmotionCell: UICollectionViewCell {
    fileprivate lazy var EmotionBtn : UIButton = UIButton()
    
    var model : EmotionModel?{
        didSet{
            guard let model = model else {
                return
            }
            EmotionBtn.setImage(UIImage.init(contentsOfFile: model.pngPath ?? ""), for: UIControlState())
            EmotionBtn.setTitle(model.codeString, for: UIControlState())
            if model.isDelete {
                EmotionBtn.setImage(UIImage(named: "compose_emotion_delete"), for: UIControlState())
            }
            if model.isEmpty {
                EmotionBtn.setImage(UIImage(named: ""), for: UIControlState())

            }
        }
    }
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}

//MARK:==========设置 UI==========
extension EmotionCell{
    func setupUI() {
       contentView.addSubview(EmotionBtn)
        EmotionBtn.frame = contentView.bounds
        EmotionBtn.isUserInteractionEnabled = false
        EmotionBtn.titleLabel?.font = UIFont.systemFont(ofSize: 32)
    }
}



